<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="utf-8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>首页</title>
<link rel="stylesheet"
	href="<%=request.getContextPath()%>/css/layui.css">
<link rel="stylesheet"
	href="<%=request.getContextPath()%>/css/index.css">
<link rel="stylesheet"
	href="<%=request.getContextPath()%>/css/calendar.css">
<link rel="stylesheet"
	href="<%=request.getContextPath()%>/css/default.css" />
<script src="<%=request.getContextPath()%>/js/emoticons.js"></script>
<script src="<%=request.getContextPath()%>/js/zh_CN.js"></script>
<script src="<%=request.getContextPath()%>/js/jquery-2.1.4.min.js"></script>
<script src="<%=request.getContextPath()%>/js/calendar.js"></script>
<script src="<%=request.getContextPath()%>/js/calendar2.js"></script>
<style>
.top_con, .bot_con {
    height: auto;  
   }
   #send{
   	bottom: 4px;
   } 
   .aaa{
   	display: inline-block;
    float: left;
    text-indent: 10px;
   }
   .b{
   	border: 1px solid;
   }
   .cc{
   	   font-size: 20px !important;
   	   text-decoration: none !important;
   }
   .delete{
   	font-size: 15px;
    text-decoration: none !important;
    font-weight: bold;
    color:red !important;
   }
   .d{
   	float: right;
   }
   .wid{ 
	    width:200px;
	    white-space:nowrap;
	    text-overflow:ellipsis;
	    -o-text-overflow:ellipsis;
	    overflow: hidden;
	    text-align: left;
 	}
 	
 	#userLi{
 		left: 255px;
 		height: 250px;
 		width: 200px; 
 		top: 0px;
 		 position: absolute; 
 		background-color: #ffffff; 
 		display: none;
 		overflow:auto; 
 		border: 1px solid #cbc8c7;
    	border-radius: 5px;
 	}
 	
 	#userLi li{
 		background: #fff;
    	margin-right: 0px;
    	cursor: pointer;
    	padding-left: 5px;
    	border-bottom: 1px solid #ddd;
 	}
 	
 	#userLi li:hover{
 		background: #e3eff5;
 	}
 	
 	.arrowspan{
 		content: '';
 		width: 0px;
 		height: 0px;
 		position: absolute;
 		top:5px;
 		left: 235px;
 		border:10px solid transparent;
 		border-right: 10px solid #cac7c7;
 		display:none;
 	}
 	
 	#selectLidt::-webkit-scrollbar {/*滚动条整体样式*/
        width: 5px;     /*高宽分别对应横竖滚动条的尺寸*/
        height: 1px;
    }
	#selectLidt::-webkit-scrollbar-thumb {/*滚动条里面小方块*/
	        border-radius: 10px;
	         -webkit-box-shadow: inset 0 0 5px rgba(0,0,0,0.2);
	        background: #aaa;
	    }
	#selectLidt::-webkit-scrollbar-track {/*滚动条里面轨道*/
	        -webkit-box-shadow: inset 0 0 5px rgba(0,0,0,0.2);
	        border-radius: 10px;
	        background: rgba(234, 229, 229,0.5);
	    }
	    
	    .selectObj{
  		background-color: #8DB6CD;
  		border: 1px solid #ccc;
  	}
  	
  	.backToday{
  	    position: absolute;
	    left: 70%;
	    top: 10px;
	    width: 20px;
	    height: 20px;
	    line-height: 20px;
	    text-align: center;
	    border-radius: 50%;
	    color: #fff;
	    background-color: rgb(255, 128, 142);
	    font-size: 14px;
  	}
  	
  	
  	
</style>
<script>
	
	//定义日期转换函数
	function dateConvert(dateParms) {
		//alert(dateParms)
		// 对传入的时间参数进行判断
		if (dateParms instanceof Date) {
			var datetime = dateParms;
		}
		//判断是否为字符串
		if ((typeof dateParms == "string") && dateParms.constructor == String) {

			//将字符串日期转换为日期格式
			var datetime = new Date(Date.parse(dateParms.replace(/-/g, "/")));

		}

		//获取年月日时分秒
		var year = datetime.getFullYear();
		var month = datetime.getMonth() + 1;
		var date = datetime.getDate();
		var hour = datetime.getHours();
		var minutes = datetime.getMinutes();
		var second = datetime.getSeconds();

		//月，日，时，分，秒 小于10时，补0
		if (month < 10) {
			month = "0" + month;
		}
		if (date < 10) {
			date = "0" + date;
		}
		if (hour < 10) {
			hour = "0" + hour;
		}
		if (minutes < 10) {
			minutes = "0" + minutes;
		}
		if (second < 10) {
			second = "0" + second;
		}

		//拼接日期格式【例如：yyyymmdd】
		var time = year + month + date;

		//或者：其他格式等
		//var time = year+"年"+month+"月"+date+"日"+hour+":"+minutes+":"+second; 

		//返回处理结果
		return time;
	}
	//var userIds = "";
	//var userCount=0;
	//添加道选中的div
	function addToSelectedUser(name, id) {
		var userId = $("#receiverArea").find("div[id=" + id + "]").attr("id");
		 var len = $("#receiverArea").find("div.user-div1").length;
		if(len<10){
		if (userId) {
			    layer.alert("已添加用户，请勿重复添加！")
		     } else {
			     $(
					"<div style='background-color:#eee;/* width:  50px; */display: inline-block;float:  left;margin-right: 10px;position:  relative;height:  30px;line-height:  30px;padding: 0 5px;' class='user-div1'><div id='"+id+"' style='float:left' class='user-div2'><span  style='margin-left:0px;color: #333;background-color:#eee;padding-left:  10px;' class='user-span1'>"
							+ name + "</span><span class='user-span2' style='cursor:pointer;color:#000;position:  absolute;right:  0;top: -11px;font-size: 1px;' onclick='removeDiv(\""+id+"\")'><img src='${ctx}/img/remove-icon-small.png' /></span></div></div>").appendTo($("#receiverArea"));
			    value=len+1+"";
			    $("#userCount").text(value);
		     }
		  }else{
			layer.alert(" 添加用户不能超过10个")
		}
	}
	//移除选中元素
	function removeDiv(aid) {
		$("#userCount").text(parseInt($("#userCount").text())-1);
		$("#receiverArea").find("div[id=" + aid + "]").parent().remove(); 
	};
	//查询用户
	function queryUsers() {
		username=$("#reciever").val()
		$.ajax({//用的是jQuery的写法
					type : "POST",//用的是post请求方式
					url : "${ctx}/workTable/searchUsers",//后台接口
					dataType : "json",//返回的数据类型 
					//async: false,
					//async: true,
					data : "username="+username,//向后台传的数据
					success : function(result) {
						//$("#receiverArea").empty();
						$("#userLi").empty();
						if (result.length>0) {
							$.each(
											result,
											function(index, term) {
												var userSpan = $('<li name="selectedUser"  onclick="addToSelectedUser(\''
														+ term.username
														+ '\',\''
														+ term.id
														+ '\')">'
														+ term.username
														+ '</li>');
												userSpan
														.appendTo($("#userLi"));
											});
						}
                           $("#userLi").css("display","block");
                           $(".arrowspan").css("display","block")
					},
					error : function(jquery) {
						layer.alert("发生错误：" + jquery.status);
					}
				});
	}
	function turnon(id) {
		layer.alert(id);
	}
	function sendMessage() {
		var text = $("#msgContent").val();
		 //alert(text);
		 if(typeof text == "undefined" || text == null || text == ""){
			    layer.alert("消息不能为空")
				return;
		 }
		if(text.length>50){
			layer.alert("消息不能超过50个字符！")
			return;
		}
		var users=$("#receiverArea").find("div");
		//console.log(users)
		var userIds="";
		for(var i=0;i<users.length;i++){
			userIds+=users[i].id+"-";
			//alert(userIds)
		};
		if(userIds==""){
			layer.alert("请选择接收人！")
			return;
		}
		
		//alert(userIds);
		$("#selectedUser").empty();
		$("#msgContent").val("");
		$(".receive").css("display", "none");
		url = "${ctx}/workTable/sendMessage";
		//改为ajax提交
		$.ajax({
			url : url,
			type : "post",
			
			data : {
				"userIds" : userIds,
				"msgContent":text
			},
			async: false,
			datatype : 'json',
			success : function(data) {
				layer.msg('发送成功', {
					  icon: 1,
					  time: 1500 //2秒关闭（如果不配置，默认是3秒）
					}, function(){
						location.reload();
					});
			},
			error : function(jquery) {
				layer.alert("发生错误：" + jquery.status);
			}
		});
		//window.location.reload();
		
	}
	//查询日程
	function querySchdule() {
		// $("#calendar").show();
		url = "${ctx}/workTable/mySchedule";
		scheduleDate = $("#schduleDate").val();
		if (scheduleDate == "now") {
			var scheduleDate = new Date();
			scheduleDate = dateConvert(scheduleDate);
			$("#schduleDate").attr("value", scheduleDate);
			$('.item-curDay').removeClass('item-curDay');
		}
		scheduleDate=dateConvert(scheduleDate);
		scheduleDate = $("#schduleDate").attr("value")
		
		var two = $("<ul></ul>");		
		
		$.ajax({
					url : url,//'${ctx}/workTable/mySchedule', //服务器的地址
					data : {
						"scheduleDate" : scheduleDate
					}, //参数
					dataType : 'json', //返回数据类型
					type : 'POST', //请求类型
					success : function(data) {
						$("#one").empty();
						var one = $("#one");
						if (data.length>0) {
							$.each(data,function(index, term) {
								var three = $("<li class='b'  onmouseover='MouseOver(this)' onmouseout='MouseOut(this)'></li>");
								var four = $("<li class='d'></li>");
								if (null != term || "" != term) {
									if(term.status == 0){
										var schdule = $("<div class='aaa wid' style='overflow:hidden;white-space:nowrap;text-overflow:ellipsis;' title='"+term.content+"'>"
												+ term.content
												+ "</div>");
										var check=$("<input style='color:blue' type='checkbox' name='check' onclick='update("+term.id+")'>");
										var c = $("<a class='layui-icon cc' href='javascript:void(0)' onclick=\"editSchdule('"
												+ term.id
												+ "',this)\">&#xe642;</a>"); 
										var d = $("<a class='layui-icon delete' href='javascript:void(0)' onclick=\"removeSchdule('"
											    + term.id
												+ "')\">&#x1006;</a>");
														schdule.appendTo(three);
														check.appendTo(four);
														c.appendTo(four);
														d.appendTo(four);
														four.appendTo(three);
														three.appendTo(two);
														two.appendTo(one);
									}else{
										var schdule = $("<div class='aaa wid' style='overflow:hidden;white-space:nowrap;text-overflow:ellipsis;'>"
												+ term.content
												+ "</div>");
										var d = $("<a class='layui-icon delete' href='javascript:void(0)' onclick=\"removeSchdule('"
											    + term.id
												+ "')\">&#x1006;</a>");
														schdule.appendTo(three);
														d.appendTo(four);
	                                                    $("<span class='layui-icon'style='color: green;'>&#xe618;</span>").appendTo(four);
	                                                    four.appendTo(three);
														three.appendTo(two);
														two.appendTo(one);
									}
								}
							})
						} else {
							$("<p style='text-align: center;'>今日暂无任何行程...</p>").appendTo(one);
						}
					}
				});
	}
	
	function update(personScheduleId){
		layer.confirm('确定完成该日程吗？', {icon: 3, title:'温馨提示'},  function(index){
			$.ajax({
				url : '${ctx}/workTable/updateStatus?id='+personScheduleId, //服务器的地址
				dataType : 'json', //返回数据类型
				type : 'POST', //请求类型
				success : function(data) {
					if (data==1) {
						layer.msg('操作成功', {
	  					  icon: 1,
	  					  time: 1000 //2秒关闭（如果不配置，默认是3秒）
	  					}, function(){
	  						location.reload();
	  					});
					}
				},
				error: function(request) {
					layer.alert("失败！");
				}
			});
			layer.close(index);
   		});
		
	}
	
	//查询我的关注
	function queryAttention() {
		attentionDate = $("#attentionDate").val();
		//alert(attentionDate)
		if (attentionDate == "now") {
			var attentionDate = new Date();
			attentionDate = dateConvert(attentionDate);
			//alert(attentionDate)
			$("#attentionDate").attr("value", attentionDate);
		}
		attentionDate = $("#attentionDate").attr("value")
		//$("#attentionContent").empty();
		var six = $("<ul></ul>");	
		$.ajax({//用的是jQuery的写法
					type : "POST",//用的是post请求方式
					url : "${ctx}/workTable/myAttention",//后台接口
					dataType : "json",//返回的数据类型 
					data : {
						"attentionDate" : attentionDate
					},//向后台传的数据
					success:function(data){
						$("#five").empty();
						var five = $("#five");
						if(data.length>0){
							$.each(data,function(index, term) {
								var three = $("<li class='b'  onmouseover='MouseOver(this)' onmouseout='MouseOut(this)'></li>");
								//var six = $("<li class='d'></li>");
								if(null != term || "" != term){
									//if(term.status == 0){
										var attention = $("<div class='aaa wid' style='cursor:pointer;color:#0000C6' onclick='queryAttentionDetail("+term.id+")'>"+ term.taskName+"</div>");
										attention.appendTo(three);
										three.appendTo(six);
										six.appendTo(five);
									/* }else{
										var attention = $("<div class='aaa wid' style='cursor:pointer;' onclick='queryAttentionDetail("+term.id+")'>"+ term.planName+ "</div>");
										attention.appendTo(three);
										three.appendTo(six);
										six.appendTo(five);
									} */
								}
							});
						}else{
							$("<p style='text-align: center;'>今日暂无任何关注...</p>").appendTo(five);
						}
					}
					
				});
	}

 	//编辑日程
	function editSchdule(schduleId,obj) {
		$(".edit").css("display", "block");
		$("#mySchduleId").val(schduleId);
		content=$(obj).parent().prev().html();
		//alert(content)
		$("#myEditSchduleContent").val(content);
		/* setTimeout(function(){
			numberLimit(document.getElementById('myEditSchduleContent'))	
		},500); */
		numberLimit(document.getElementById('myEditSchduleContent'));
		
	} 
	//删除日程
	function removeSchdule(schduleId) {

		layer.confirm('您确定要删除？', {
			  btn: ['是的','取消'] //按钮
			}, function(){
				url = "${ctx}/workTable/deleteSchdule";
				$.ajax({
					url : url,//'${ctx}/workTable/mySchedule', //服务器的地址
					type : "POST", //请求类型ypeof(data))
					data : {
						"schduleId" : schduleId
					},
					success : function(data) {
						if(data == "success"){
							layer.alert('删除成功！',function(){
								location.reload(true);
							});
						}else if(data == "failure"){
							layer.alert('删除失败！');
						}
					}
				});
			}, function(){
				location.reload(true);
			});
	}
		/* url = "${ctx}/workTable/deleteSchdule";
		$.ajax({
			url : url,//'${ctx}/workTable/mySchedule', //服务器的地址
			dataType : 'json', //返回数据类型
			type : "POST", //请求类型ypeof(data))
			data : {
				"schduleId" : schduleId
			},
			success : function(data) {
				if(data == "success"){
					layer.alert('删除成功！');
					location.reload(true);
				}else if(data == "failure"){
					layer.alert('删除失败！');
				}
			}
		}); */
		//window.location.reload();
	
	function addMySchdule() {
		content = $("#mySchduleContent").val();
		if (null == content || "" == content.trim()) {
			layer.alert("内容不能为空")
			return;
		}
		scheduleDate = $("#schduleDate").val();
		if (scheduleDate == "now") {
			var scheduleDate = new Date();
			scheduleDate = dateConvert(scheduleDate);
			$("#schduleDate").attr("value", scheduleDate);
		}
		scheduleDate = $("#schduleDate").attr("value")
		date = scheduleDate.substring(0, 4) + "/"
				+ scheduleDate.substring(4, 6) + "/"
				+ scheduleDate.substring(6, 8);
		scheduleDate = new Date(date)
		data = {
			"scheduleDate" : scheduleDate,
			"content" : content
		};
		url = "${ctx}/workTable/addMySchdule";
		$.ajax({
			url : url, //服务器的地址
			dataType : 'json', //返回数据类型
			type : "POST", //请求类型ypeof(data))
			contentType : "application/json",
			data : JSON.stringify(data),
			success : function(data) {
				layer.msg('添加成功', {
					  icon: 1,
					  time: 1000 //2秒关闭（如果不配置，默认是3秒）
					}, function(){
						location.reload();
				});
			}
		});
		$(".date").css("display", "none");
	}
	//更新日程
	function updateMySchdule(content) {
		schduleId = $("#mySchduleId").val();
		content = $("#myEditSchduleContent").val();
		scheduleDate = $("#schduleDate").val();
		if (scheduleDate == "now") {
			var scheduleDate = new Date();
			scheduleDate = dateConvert(scheduleDate);
			$("#schduleDate").attr("value", scheduleDate);
		}
		scheduleDate = $("#schduleDate").attr("value")
		date = scheduleDate.substring(0, 4) + "/"
				+ scheduleDate.substring(4, 6) + "/"
				+ scheduleDate.substring(6, 8);
		scheduleDate = new Date(date)
		data = {
			"scheduleDate" : scheduleDate,
			"content" : content,
			"id" : schduleId
		};
		url = "${ctx}/workTable/updateMySchdule";
		$.ajax({
			url : url, //服务器的地址
			dataType : 'json', //返回数据类型
			type : "POST", //请求类型ypeof(data))
			contentType : "application/json",
			data : JSON.stringify(data),
			success : function(data) {
				layer.msg('保存成功', {
					  icon: 1,
					  time: 1000 //2秒关闭（如果不配置，默认是3秒）
					}, function(){
						location.reload();
				});
			}
		});
	}
	//删除关注
	function removeAttention(attentionId) {
		url = "/ctm-touchpoint-web/workTable/deleteAttention";
		$.ajax({
			url : url,//'${ctx}/workTable/mySchedule', //服务器的地址
			dataType : 'json', //返回数据类型
			type : "POST", //请求类型ypeof(data))
			data : {
				"attentionId" : attentionId
			},
			success : function(data) {
				//alert(data.msg);
				//location.reload(true);
			}
		});
		queryAttention();
	}
	
	var endSum = 0;//切换到已办不需要后台取数据
	
	//添加事件显示不同提醒消息列表
	function addEvent() {
		$("#msgType").find("li").click(function() {//切换提醒消息的类型触发事件（二级选项卡）
			$("#msgRemind .message").remove();//移除所有消息
			$("#msgType").find("li").removeClass("active");//移除按钮
			$(this).addClass("active");//添加按钮
			returnJson(this);
		});
		$("#auditType").find("li").click(function() {//切换审批消息的类型触发事件（二级选项卡）
			//$("#auditStatus .message").remove();//移除所有消息
			$("#auditType").find("li").removeClass("active");//移除按钮
			$(this).addClass("active");//添加按钮
			$("#auditStatus .message:not(.endCase)").remove();
			
			if (this.id == 'end' && $(".endCase").length != 0) {//切换为已办且有数据直接显示数据
				$("#auditSum").append("<span>"+endSum+"</span>");
				$(".endCase").attr("style","display:inline");
			}else{
				$(".endCase").attr("style","display:none");//切换为待办或无数据已办去后台取数据
				returnJson(this);
			}
		});

		$("#msgSum").click(function() {//在审批和提醒之间切换触发事件（一级选项卡）
			$("#auditSum").html("审批");//清空消息数量
			$("#msgRemind .message").remove();//移除消息列表

			$("#msgType").find("li").removeClass("active");//移除按钮
			$("#guard").addClass("active");//添加按钮

			returnJson(document.getElementById('guard'));
		});
		$("#auditSum").click(function() {//（一级选项卡）
			$("#msgSum").html("提醒");//清空消息数量
			//$("#auditStatus .message").remove();//移除消息列表
			$("#auditStatus .message:not(.endCase)").remove();

			$("#auditStatus").find("li").removeClass("active");//移除按钮
			$("#todo").addClass("active");//添加按钮

			returnJson(document.getElementById('todo'));
		});
	}
	
	/* 使用ajax获取提醒消息*/
	function returnJson(inpu) {
		var type = '';
		var name = $(inpu).html();//获取tab标签名
		var sumIpu = '';
		$.ajax({
					//async : false,
					type : "get", //请求的方式，也有get请求
					url : "${ctx}/msgremind/msg?number="+Math.random(), //请求地址，后台提供的,这里我在本地自己建立了个json的文件做例子
					data : {
						type : name
					},//data是传给后台的字段，后台需要哪些就传入哪些
					dataType : "json", //json格式，后台返回的数据为json格式的。
					async: false ,
					success : function(result) {
						if (result == null) {
							return;
						}
						//var dataObj = JSON.parse(result), //返回的result为json格式的数据
						var dataObj = result,
						con = '';//公共标签内容
						var sum = 0;//记录
						 if (name=="消息") {//不同提醒类型不同的页面内容
			                   //con += '<div class="message" ><button class="layui-btn layui-col-md-offset10" onclick="readingMarker(this)" value="all">全部已读</button></div>';
			                   $.each(dataObj, function(index, item){
			                	   if (item.originatorName=="系统") {//事前提醒消息
			                		   var taskType = '<span class="tag">事前</span><p style="color: black" class="con3">消息：系统给你发送一条事前提醒消息</p><a href="${ctx}'+item.linkMethod+'?1=1&planTaskId='+item.planTaskId+'&msg='+item.id+'"><p class="con1">'+item.instanceName+'</p></a>';
			                		   var btn = '';
			                		   //内容添加链接
									}else{//消息
									   var taskType = '<span class="tag">消息</span><p class="con3">消息：'+item.originatorName+'给你发送了一条消息</p><p style="color:black" class="con1">'+item.instanceName+'</p>';
				                	   if(item.status==1){ //为未读
				                		   var btn = '<div class="rg_msg"><button class="layui-btn layui-btn-xs layui-btn-warm" value1="'+item.originatorName+'" value="'+item.id+'" onclick="readingMarker(this)">确认</button></div>';
				                		   //var mark='<button class="layui-btn layui-btn-warm" value1="'+item.createParty+'" value="'+item.id+'" onclick="readingMarker(this)" >确认已读</button></div></li></ul>';
				                	   }else if(item.status==2){//为已读
				                		   //var mark='<button class="layui-btn layui-btn-disabled" value="'+item.id+'" >已读</button></div></li></ul>';
				                		   var btn = '<div class="rg_msg"><span class="layui-btn layui-btn-xs layui-btn-normal"  onclick="return false;">已读</span></div>';
				                		   sum++;
				                	   }else{return true;}
										
									}
			                       con += '<ul class="message"><li><div class="lf_msg"><span class="tag">消息</span>'+taskType+'<p class="con2">'+item.receiveTime+'&nbsp;由 <span class="bl_txt">'+item.originatorName+'</span> 发送</p></div>'+btn+'</li></ul>';
			                   });
			                   sumIpu = "msgSum";
							}        	   
						   if (name=="预警"){
			                   $.each(dataObj, function(index, item){
			                	   
			                	   if(item.status==1){ //添加预警按钮和标记
			                		   //var content='<button class="layui-btn" value="'+item.id+'" onclick="window.location=\'${ctx}'+item.linkMethod+'?1=1&planTaskId='+item.planTaskId+'&msg='+item.id+'\'">任务汇报</button></div></li></ul>';
			                		   var taskType = '<span class="tag2">预警</span><p style="color: black" class="con3">预警:您的任务延期了</p>';
			                	   }else{return true;}
			                	   
/* 			                	   else if(item.status==2){
				                		  // var content='<button class="layui-btn layui-btn-disabled" value="'+item.id+'" >已汇报</button></div></li></ul>';
				                		   var taskType = '<span class="tag">预警</span><p style="color: black" class="con3">预警:您的任务延期了</p>';
				                	   } */
			                	   
			                       con += '<ul class="message"><li><div class="lf_msg">'+taskType+'<a href="${ctx}'+item.linkMethod+'?1=1&planTaskId='+item.planTaskId+'&msg='+item.id+'&msgType='+item.type+'"><p class="con1">'
			                       +item.instanceName+'</p></a><p class="con2">'+item.receiveTime+'&nbsp;由 <span class="bl_txt">'+item.originatorName+'</span> 发送</p></div></li></ul>';
			                   });
			                   sumIpu = "msgSum";
						   }
						   if (name=="任务"){
			                   $.each(dataObj, function(index, item){
			                	   
			                	   if(item.type==3){//事前提醒
			                		   var taskType = '<span class="tag3">填报</span><p style="color: black" class="con3">事中任务:你有任务需要填报</p>';
			                	   }else if(item.type==4){//事中提醒
			                		   var taskType = '<span class="tag3">填报</span><p style="color: black" class="con3">到期任务:你有任务需要填报</p>';
			                	   }else if(item.type==5){ //到期提醒
			                		   var taskType = '<span class="tag4">评分</span><p class="con3">任务评分:你有任务需要评分</p>';
			                	   }else{return true;}			                		   
			                	   
			                       con += '<ul class="message"><li><div class="lf_msg">'+taskType+'<a href="${ctx}'+item.linkMethod+'?1=1&planTaskId='+item.planTaskId+'&msg='+item.id+'&msgType='+item.type+'"><p class="con1">'
			                       +item.instanceName+'</p></a><p class="con2">'+item.receiveTime+'&nbsp;由 <span class="bl_txt">'+item.originatorName+'</span> 发送</p></div></li></ul>';
			                   });
			                   sumIpu = "msgSum";
			               }
						   if (name=="待办"){//(1.任务审批 2.计划创建 3.计划变更 4.体系创建)
			                   $.each(dataObj, function(index, item){
			                	   
			                	   if (item.instanceName == undefined) {//不显示接口在本地库无关联的数据
			                		    sum++;
										return true;
								   }
			                	   
							    	if (item.isRead == "read") {//判断待阅还还是待办
										var read = '待</p><i class="layui-icon">阅</i>';
										var name = "传阅";
										var s = "Read";
									}else if(item.isRead == "noRead"){
										var read = '待</p><i class="layui-icon">办</i>';
										var name = "审批";
										var s = "";
									}else{
										var read = '</p><i class="layui-icon"></i>';
										var s = "";
										var name = "";
									}
							    	
							    	if (item.rejectStatus == 4) {//(4.审批驳回确认  5.审批驳回记录)
										name = "进行驳回确认";
									}
							    	
							    	var displayName =  encodeURI(encodeURI(item.displayName));
							    	
								    if (item.apStatus == 2) {
										var linkMethod = '<span class="ring2"></span><a href="${ctx}/approval/approvalPlanCreation'+s+'Todo?flowType=Plan&flowId='+item.instanceId+'&displayName='+displayName+'&baseObjectID='+item.baseObjectID+'&activityCode='+item.activityCode+'">';
									}else if(item.apStatus == 3){
										var linkMethod = '<span class="ring3"></span><a href="${ctx}/approval/approvalPlanChange'+s+'Todo?flowType=PlanChange&flowId='+item.instanceId+'&displayName='+displayName+'&baseObjectID='+item.baseObjectID+'&activityCode='+item.activityCode+'">';
									}else if(item.apStatus == 4){
										var linkMethod = '<span class="ring"></span><a href="${ctx}/approval/approvalTemplateCreation'+s+'Todo?flowType=PlanTemplate&flowId='+item.instanceId+'&displayName='+displayName+'&baseObjectID='+item.baseObjectID+'&activityCode='+item.activityCode+'">';
									}else if(item.apStatus == 1){
										var linkMethod = '<span class="ring4"></span><a href="${ctx}'+item.linkMethod+'?taskAppFlowId='+item.taskAppFlowId+'">';
									}else {return;}
								    con += '<ul class="message"><li><div class="lf_msg" style="width: 85%" >'+linkMethod+'<p class="con3">审批:你有<font color="blue">'
				                	+item.instanceName+'</font>需要'+name+'</p></a><p class="con2">'+item.receiveTime+'&nbsp;由 <span class="bl_txt">系统</span> 发送</p></div><div class="rg_msg" style="width: 8%"><p class="layui-icon" style="color:red;">'+read+'</div></li></ul>';
			                   });
			                   sumIpu = "auditSum";
			               }
						   if (name=="已办"){//(1.任务审批 2.计划创建 3.计划变更 4.体系创建)
			                   $.each(dataObj, function(index, item){
			                	   
			                	   if (item.instanceName == undefined) {//不显示接口在本地库无关联的数据
			                		    sum++;
			                			return true;
								   }
			                	   
							    	if (item.isRead == "read") {
										var read = '已</p><i class="layui-icon" style="color:#5FB878;">阅</i>';
										var name = "传阅";
										var s = "Read";
									}else if(item.isRead == "noRead"){
										var read = '已</p><i class="layui-icon" style="color:#5FB878;">办</i>';
										var name = "审批";
										var s = "";
									}else{
										var read = '</p><i class="layui-icon" style="color:#5FB878;"></i>';
										var s = "";
										var name = "";
									}
							    	
							    	if (item.rejectStatus == 5) {//(4.审批驳回确认  5.审批驳回记录)
										name = "进行驳回确认";
									}
							    	
			                	   if (item.apStatus == 1) {//任务审批
			                		   var linkMethod = '<span class="ring4"></span><a href="${ctx}'+item.linkMethod+'?taskAppFlowId='+item.taskAppFlowId+'&baseObjectID='+item.baseObjectID+'">';
								   }else if(item.apStatus == 2){//计划创建
									   var linkMethod = '<span class="ring2"></span><a href="${ctx}/approval/approvalPlanCreation'+s+'End?flowId='+item.instanceId+'&baseObjectID='+item.baseObjectID+'">';
								   }else if(item.apStatus == 3){//计划变更
									   var linkMethod = '<span class="ring3"></span><a href="${ctx}/approval/approvalPlanChange'+s+'End?flowId='+item.instanceId+'&baseObjectID='+item.baseObjectID+'">';
								   }else if(item.apStatus == 4){//体系创建
									   var linkMethod = '<span class="ring"></span><a href="${ctx}/approval/approvalTemplateCreation'+s+'End?flowId='+item.instanceId+'&baseObjectID='+item.baseObjectID+'">';
								   }else {return;}
			                	   
			                	   con += '<ul class="message endCase"><li><div class="lf_msg" style="width: 85%">'+linkMethod+'<p class="con3">审批:你有<font color="blue">'
				                	+item.instanceName+'</font>已'+name+'</p></a><p class="con2">'+item.receiveTime+'&nbsp;由 <span class="bl_txt">系统</span> 发送</p></div><div class="rg_msg" style="width: 8%"><p class="layui-icon" style="color:#5FB878;">'+read+'</div></li></ul>';
			                   });
			                   sumIpu = "auditSum";
			                   endSum = Object.keys(dataObj).length-sum;
			               }
						   
						   console.log(sum);
		                   $("#auditStatus").append(con); //把内容入到这个div中即完成
		                   $("#msgRemind").append(con); //把内容入到这个div中即完成
		                   
		                   $("#"+sumIpu).append("<span>"+(Object.keys(dataObj).length-sum)+"</span>");//动态改变消息数量
		               }    
				});
	}
	//ajax将列表标记改为已读取
	function readingMarker(obj) {
		var msgId = obj.value;
		if (msgId == "all") {//判断是否为全部已读
			var url = "${ctx}/msgremind/markerAll";
		} else {
			var url = "${ctx}/msgremind/marker";
		}

		$.ajax({
			type : "get",
			url : url,
			data : {
				id : msgId
			},
			success : function() {
				//console.log($(obj).attr("value1"));
				if ($(obj).attr("value1") == "系统") {//对页面进行删除操作，不需要重加载
					$(obj).parent().parent().parent(".message").remove();
					return true;
				}

				$("#msgRemind .message").remove();//移除消息列表
				$("#msgType").find("li").removeClass("active");//移除按钮
				$("#msg").addClass("active");//添加按钮
				returnJson(document.getElementById('msg'));
			}
		});
	}
	function init() {
		//alert("a")
		$
		.ajax({
			url : '${ctx}/repository/searchKey', //服务器的地址
			data : {
				keyword : $("#search-text")
						.val(),
				pageSize:5
			}, //参数
			dataType : 'json', //返回数据类型
			type : 'POST', //请求类型
			success : function(data) {
				if (data.length>0) {
					//遍历data，添加到自动完成区
					$
							.each(
									data,
									function(
											index,
											term) {
										var content = term.keyWord;
										var articleId = term.id;
										//alert(contentId)
										var li = $("<li></li>")
										var children = $('<div title="'+term.theme+'" onclick="javascript:showContent('+articleId+')" style="width:130px;margin:auto;color: blue;cursor: pointer;overflow:hidden; white-space:nowrap;  text-overflow:ellipsis;" >'
											+ term.theme + '</div><br>');
										children
												.appendTo(li);
										/* $(
												"#article")
												.empty(); */
										$(
												"#article")
												.append(
														li);
									});
				}
			}
		});
	}
	function showRepository(articleId,content){
		//alert(content)
		$("#repositoryView").empty();
		//div=$("<div style='overflow:scroll; width:280px; height:150px;'><span style='float:right' font-size='20px'>...</span></div> ");
		//content="<li align='center'>"+content+"</li>"
		span="<span style='font-size:20px;float:right;cursor: pointer;'  title='在新页面中打开' onclick=\"showInNewView("+articleId+")\">...</span>";
		content="<li align='center'>"+content+"</li>";
		$("#repositoryView").append(span);
		$("#repositoryView").append(content);
	}
	function showInNewView(articleId){
		window.location.href="${ctx}/repository/repositoryView?articleId="+articleId;
	}
	window.onload = function() {
		init();
	}
	function openMsg(){//加载页面后根据参数显示不同类型消息内容（2.消息;3.任务-->事中;4.任务-->到期;5.任务-->评分;7.审批待办;8.审批已办;其他：预警）
		if("${msgType}"==3||"${msgType}"==4 ||"${msgType}"==5){
			
			$("#msgSum").addClass("layui-this");//一级选项卡(提醒)
			$("#msgRemind").addClass("layui-show");	//二级选项卡(标题：消息任务和预警)		
			$("#task").addClass("active");//二级选项卡(内容：任务)
			returnJson(document.getElementById("task"));//任务
		}else if("${msgType}"==2){
			
			$("#msgSum").addClass("layui-this");
			$("#msgRemind").addClass("layui-show");			
			$("#msg").addClass("active");
			returnJson(document.getElementById("msg"));//消息
		}else if("${msgType}"==7){
			
			$("#auditSum").addClass("layui-this");
			$("#auditStatus").addClass("layui-show");			
			$("#todo").addClass("active");
			returnJson(document.getElementById("todo"));//审批待办
		}else if("${msgType}"==8){
			
			$("#auditSum").addClass("layui-this");//一级选项卡
			$("#auditStatus").addClass("layui-show");//二级选项卡(标题)
			$("#end").addClass("active");//二级选项卡(内容)
			returnJson(document.getElementById("end"));//审批已办
		}else{
			$("#msgSum").addClass("layui-this");
			$("#msgRemind").addClass("layui-show");			
			$("#guard").addClass("active");
			returnJson(document.getElementById("guard"));//默认预警
		};
		addEvent();
	}
	$(function(){
		openMsg();
	})
	
	function queryAttentionDetail(id){
		window.location.href="${ctx}/planTask/planTaskDetailUnpms?id="+id;
	}
</script>
<style type="text/css">
#search {
	text-align: center;
	position: relative;
}

.autocomplete {
	border: 1px solid #9ACCFB;
	background-color: white;
	text-align: left;
}

.autocomplete li {
	list-style-type: none;
}

.clickable {
	cursor: default;
}

.highlight {
	background-color: #9ACCFB;
}
</style>
</head>
<body>
	<div>
		<div class="box clearfix">
			<div class="layui-side">
				<div class="top_con">
					<div class="person">
						<i class="layui-icon" style="font-size: 30px; color: #cecece;">&#xe620;</i>
						<a href="javascript:;"><img src="http://t.cn/RCzsdCq"
							class="layui-nav-img"></a>
						<div class="msg">
							<span class="name">${currentUser.username }</span><span class="job">${JobName}</span>
							<p class="company">${SubcompanyName}</p>
						</div>
					</div>
					<div class="msg_con">
						<div class="layui-tab">
							<ul class="layui-tab-title" id="message">
								<li>消息</li>
								<a href="javascript:;" class="layui-btn layui-btn-primary"
									style="float: right; margin-top: 6px" id="receive">接收人<span><font id="userCount">0</font>/10人</span></a>
							</ul>
							<div id="selectedUser"></div>
							<div clas="user" id="user" color='red'></div>
							<div class="layui-tab-content">
								<div class="layui-tab-item layui-show">
									<form id="sysUser" style="position: relative;">
										<input type="hidden" name="userIds" id="userIds"></input>
										<textarea id="msgContent"  style="overflow:hidden; resize:none;width: 295px; height: 140px; border:1px solid #d6cfcf;" maxlength="50"></textarea>
										<a href="javascript:;" id="send">发送</a>
									</form>
								</div>

							</div>
						</div>
					</div>
					<!-- 接收人弹框 -->
					<div class="receive" id="receiverPerson">
						<div class="search bar1">
							<form>
								<input type="text" placeholder="接收人" style="margin-left: 10px;"
									id="reciever">
									<!-- width: 237px; height: 100px;  -->
								<span class="arrowspan"></span>
								<ul id="userLi">
								</ul>
								<!-- <input type="text" placeholder="接收人" list="reciverList" class="selectInput" name="reciverName" id="reciverName" value="" onfocus="fuzzySearch.call(this)" /> -->
							</form>
						</div>
						<div id="receiverArea" style="height: 253px; overflow: auto"></div>
						<!-- <div class="add"><span>10/100人</span><button>添加</button></div> -->
					</div>
				</div>
				<div class="bot_con">
					<div class="layui-tab">
						<ul class="layui-tab-title">
							<li class="layui-this" id="schduleli" style="font-weight:bold;">我的日程</li>
							<li id="myAttention"  style="font-weight:bold;">我的关注</li>
							<li style="text-align: right;"><i class="layui-icon"
								style="color: #000" id="mySchdule">&#xe654;</i></li>
						</ul>
						<div class="layui-tab-content">
							<div class="layui-tab-item layui-show">
								<input type="hidden" id="schduleDate" value="now"> </input> <input
									type="hidden" id="attentionDate" value="now"> </input>
								<div id="calendar" class="calendar"></div>
								<div class="trip" id="trip">
									<div class="" style="width: 274px;margin-left: 13px;" id="one">
									</div>
								</div>
							</div>
							<div class="layui-tab-item">
								<div id="calendar2" class="calendar"></div>
								<div id="attentionContent" class="trip" date="" >
									<!-- <p>今日暂无任何关注...</p> -->
                                     <div class="" style="width: 274px;margin-left: 13px;" id="five">
									</div>
								</div>
							</div>
						</div>
					</div>
					<!-- 添加日程弹框 -->
					<div class="date">
						<!-- 日程标题:<input id="mySchduleTitle"></input> -->
						<textarea style=" font-size:12px; color:#000000" placeholder="请输入日程详细内容..." id="mySchduleContent" maxlength="50" onKeyDown="LimitTextArea(this)" onKeyUp="LimitTextArea(this)" onkeypress="LimitTextArea(this)"></textarea>
						<p>
							<span><font id="currNum">50</font>/50字</span><a href="javascript:;" class="addMySchdule"
								id="addMySchdule">添加</a>
								<a href="javascript:;" class="addMySchdule"
								id="cancel">取消</a>
						</p>
					</div>
					<!-- 添加日程弹框 -->

					<!-- 编辑日程弹框 -->
					<div class="edit">
						<input type="hidden" id="mySchduleId"></input>
						<textarea style="color: black;" placeholder="请输入日程详细内容。。。" id="myEditSchduleContent" maxlength="50" onKeyDown="numberLimit(this)" onKeyUp="numberLimit(this)" onkeypress="numberLimit(this)"></textarea>
						<p>
							<span><font id="num">50</font>/50字</span><a href="javascript:;" class="editMySchdule"
								id="editMySchdule">保存</a>
								<a href="javascript:;" class="addMySchdule"
								id="abolish">取消</a>
						</p>
					</div>
					<!-- 编辑日程弹框 -->
				</div>
			</div>

			<div class="layui-body" style="width: 72%; margin-top: 20px;">
				<!-- 内容主体区域 -->
				<div class="main_con" style="min-height: 650px;">
					<div class="layui-tab">
						<div class="tab_con clearfix">
							<ul class="layui-tab-title">
								<li id="msgSum">提醒</li>
								<li id="auditSum">审批</li>
							</ul>
						</div>
						<div class="layui-tab-content">
							<div class="layui-tab-item" id="msgRemind">
								<ul class="layui-tab-title2 clearfix" id="msgType">
									<li id="guard">预警</li>
									<li id="task">任务</li>
									<li id="msg">消息</li>
								</ul>
							</div>
							<div class="layui-tab-item" id="auditStatus">
								<ul class="layui-tab-title2 clearfix" id="auditType">
									<li id="todo">待办</li>
									<li id="end">已办</li>
								</ul>
							</div>
						</div>
					</div>
				</div>
				<div class="rg-body">
					<ul class="top_con" style="border: none;min-height:600px;position: relative;">
						<p class="layui-elem-quote">知识库</p>
						<div class="search bar1" id="search">
							<form id="myForm">
								<input type="text" id="search-text" placeholder="请输入您要搜索的内容..." />
								<!-- <button type="button" id="btn">查询</button> -->
								<!-- type="submit" -->
							</form>
						</div>
						<div align="right" id="conceal" style="visibility: hidden;height:30px;color: black;cursor: pointer;" title="在新页面打开">.&nbsp;.&nbsp;.</div>
						<h1 id="themes" style="visibility: hidden;text-align: left;"></h1> 
						<div id="keywordName" style="margin-top: 20px"></div>
						<div id="repositoryView">
							<h4 align="center" style="color:green">热门搜索</h4>
							<div id="article"></div>
						</div>
						<div id="selectLidt" style="overflow-y: auto;height:310px;"></div>
					</ul>
				</div>
			</div>
		</div>
	</div>
	</div>
	</div>
	<script type="text/javascript">
		$("#cancel").click(function(){
			$("#mySchduleContent").val(""); 
			$("#currNum").html(50);
			$(".date").hide();
		})
		$("#abolish").click(function(){
			$(".edit").hide();
		})
		$(function() {
			var $search = $("#search")
			var $searchInput = $('#search-text')
			var parent = $('#article')
			//关闭浏览器提供给输入框的自动完成 
			$searchInput.attr('autocomplete', 'off');
			//创建自动完成的下拉列表，用于显示服务器返回的数据,插入在搜索按钮的后面，等显示的时候再调整位置 
			var $autocomplete = $('<div class="autocomplete" id="auto"></div>')
					.hide().insertAfter('#search-text');
			//清空下拉列表的内容并且隐藏下拉列表区 
			var clear = function() {
				$autocomplete.empty().hide();
			};
			//注册事件，当输入框失去焦点的时候清空下拉列表并隐藏 
			$searchInput.blur(function() {
				setTimeout(clear, 500);
			});
			//下拉列表中高亮的项目的索引，当显示下拉列表项的时候，移动鼠标或者键盘的上下键就会移动高亮的项目，想百度搜索那样 
			var selectedItem = null;
			//timeout的ID 
			var timeoutid = null;
			//设置下拉项的高亮背景 
			var setSelectedItem = function(item) {
				//更新索引变量 
				selectedItem = item;
				//按上下键是循环显示的，小于0就置成最大的值，大于最大值就置成0 
				if (selectedItem < 0) {
					selectedItem = $autocomplete.find('li').length - 1;
				} else if (selectedItem > $autocomplete.find('li').length - 1) {
					selectedItem = 0;
				}
				//首先移除其他列表项的高亮背景，然后再高亮当前索引的背景 
				/* $autocomplete.find('li').removeClass('highlight').eq(
						selectedItem).addClass('highlight'); */
			};

			$searchInput.bind('input porpertychange', function() {
				$("#auto").empty();
				$autocomplete.empty();
				//$("#article").empty();
				//setTimeout(ajax_request,500);
				ajax_request();
				//window.location.href="${ctx}/repository/repositoryView?articleId="+articleId;
			});
			//ajax請求
			function ajax_request() {
				$autocomplete.html("");
				$autocomplete.empty();
				if($("#search-text").val()){
					//ajax服务端通信
					$.ajax({
						url : '${ctx}/repository/searchKey', //服务器的地址
						data : {
							keyword : $("#search-text").val(),
							pageSize : 0
						}, //参数
						dataType : 'json', //返回数据类型
						type : 'POST', //请求类型
						async: false,
						success : function(data) {
							if (data.length) {
								//遍历data，添加到自动完成区
								$.each(data,function(index, term) {
										var content = term.keyWord;
										var articleId = term.id;
										//alert(contentId)
										var li = $("<li algin='center'></li>")
										/* var children = $('<a style="color: blue" >'
												+ content
												+ '</a><br>');
										children.attr("href","${ctx}/repository/details?articleId="+ articleId) */
										var children = $('<div onclick="javascript:showContent('+articleId+')" onmouseover="MouseOver(this)" onmouseout="MouseOut(this)">'
												+ term.theme + '</div>');
										children.appendTo(li);
										$autocomplete.append(li);
										//parent.empty();
										//parent.append(li);
										//创建li标签,添加到下拉列表中
										/* $('<li></li>').text(term.keyWord)
												.appendTo($autocomplete)
												.addClass('clickable')
												.hover(
														function() {
															//下拉列表每一项的事件，鼠标移进去的操作
															$(this).siblings().removeClass('highlight');
															$(this).addClass('highlight');
															selectedItem = index;
														},
														function() {
															//下拉列表每一项的事件，鼠标离开的操作
															$(this).removeClass('highlight');
															//当鼠标离开时索引置-1，当作标记
															selectedItem = -1;
														})
												.click(function() {
														//鼠标单击下拉列表的这一项的话，就将这一项的值添加到输入框中
														$searchInput.val(term.keyWord)
														parent.empty();
														//清空并隐藏下拉列表
														$autocomplete.empty().hide();
														//console.log(term);
														showRepository(term.id,term.keyWord);
														//ajax_request();
														//window.location.href="${ctx}/repository/repositoryView?articleId="+term.id;
												}); */
											});
								//事件注册完毕
								//设置下拉列表的位置，然后显示下拉列表
								$autocomplete.css('width', $searchInput.css('width'));
								$autocomplete.css({
									'position' : 'absolute',
									'left' : 35 + "px",
									'top' : 37 + "px",
									'max-height': 200+"px",
									'overflow-y': 'auto'
								});
								setSelectedItem(0);
								//显示下拉列表
								$autocomplete.show();
							}else{
								var li = $("<li algin='center'></li>")
								var children = $('<div style="color: #666;" >暂无相关数据</div>');
								/* children.attr("href",
										"showContent("+articleId+")"
												) */
								children.appendTo(li);
								$autocomplete.append(li);
								$autocomplete.css('width', $searchInput.css('width'));
								$autocomplete.css({
									'position' : 'absolute',
									'left' : 35 + "px",
									'top' : 37 + "px",
									'max-height': 200+"px",
									//'margin-left':(parseInt($searchInput.css('width'))/-2)+"px"
								});
								$autocomplete.show();
							}
						}
					});
				}else{
					$autocomplete.hide();
				}
			}
			$("#btn").click(function() {
				$("#keywordName").empty();
				var keywordVal = $("#search-text").val();
				if(keywordVal){
					$.ajax({
						url : '${ctx}/repository/preciseQuery', //服务器的地址
						data : {
							keyword : keywordVal
						}, //参数
						dataType : 'json', //返回数据类型
						type : 'POST', //请求类型
						async: false,
						success : function(data) {
							if (data.length) {
								//遍历data，添加到自动完成区
								$.each(data,function(index,term) {
									var content = term.keyWord;
									var articleId = term.id;
									var li = $("<li></li>")
									/* var children = $('<a style="color: blue" >'
											+ content
											+ '</a><br>');
									children.attr("href","${ctx}/repository/details?articleId="+articleId) */
									var children = $('<div title="'+content+'" onclick="javascript:showContent('+articleId+')" style="width:130px;margin:auto;color: blue;cursor: pointer;overflow:hidden; white-space:nowrap;  text-overflow:ellipsis;"  >'
											+ content + '</div><br>');
									children.appendTo(li);
									$("#article").empty();
									HiddenContent();
									$("#keywordName").append(li);
								});
							}else{
								emptyData();
							}
						}
					});
				}else{
					$.ajax({
						url : '${ctx}/repository/preciseQuery', //服务器的地址
						data : {
							keyword : keywordVal
						}, //参数
						dataType : 'json', //返回数据类型
						type : 'POST', //请求类型
						async: false,
						success : function(data) {
							//alert(data)
							if (data.length) {
								//遍历data，添加到自动完成区
								$("#keywordName").append("<h4 align='center' style='color:green'>热门搜索</h4>");
								$.each(data,function(index,term) {
									var content = term.theme;
									var articleId = term.id;
									var li = $("<li></li>")
									/* var children = $('<a style="color: blue" >'
											+ content
											+ '</a><br>');
									children.attr("href","${ctx}/repository/details?articleId="+articleId) */
									var children = $('<div title="'+content+'" onclick="javascript:showContent('+articleId+')" style="width:130px;margin:auto;color: blue;cursor: pointer;overflow:hidden; white-space:nowrap;  text-overflow:ellipsis;" >'
											+ content + '</div><br>');
									children.appendTo(li);
									$("#article").empty();
									HiddenContent();
									$("#keywordName").append(li);
									$("#conceal").css("visibility","hidden");
									$("#selectLidt").hide();
									$("#themes").css("visibility","hidden");
									$("#keywordName").css("visibility","visible");
								});
							}else{
								emptyData();
							}
						}
					});
				}
			});
			/* receiveUserFlag = true;
			$("#receive").click(function() {
				if (receiveUserFlag) {
					 //$("#userCount").text("0");
					$(".receive").css("display", "block");
					receiveUserFlag = false;
				} else {
					$(".receive").css("display", "none");
					receiveUserFlag = true;
				}
			}); */
			
			/* $(document).click(function(event){
				if (receiveUserFlag) {
					$(".receive").css("display", "block");
					receiveUserFlag = false;
				} else {
					$(".receive").css("display", "none");
					receiveUserFlag = true;
				}
			});
 */
			$("#send").click(function() {
				sendMessage();
			});
		});
		
		function emptyData(){
			//清空之前的内容
			$("#selectLidt").html("");
			//隐藏按钮
			$("#conceal").css("visibility","hidden");
			$("#themes").css("visibility","hidden");
			$("#keywordName").css("visibility","visible");
			//提示居中
			$("#keywordName").css("text-align","center");
			$("#keywordName").html("暂无相关数据");
			HiddenContent();
		}
		
		$(document).ready(
		
		//我的日程页面一加载就触发查询当天日程
		function() {
			init();
			querySchdule();
		});
		
		//显示添加日程的div
		$("#mySchdule").click(function() {
			//$("#mySchdule").show();
			//alert("1")
			$(".date").css("display", "block")
		});
		//添加日程
		$("#addMySchdule").click(function() {
			addMySchdule();
			$("#trip").empty();
			querySchdule();
		});
		//编辑日程
		$("#editMySchdule").click(function() {
			content=$("#myEditSchduleContent").val();
			//alert(content)
			updateMySchdule(content);
			$("#trip").empty();
			querySchdule();
		});
		//搜索发送人
	 	$("#reciever").bind('input porpertychange', function() {
			//$("#receiverArea").empty();
			//$("#userLi").focus();
			//$("#receiverArea").empty();
			$("#reciever").attr('autocomplete', 'on');
			queryUsers();
		}); 
	 	
		//点击我的关注
		$("#myAttention").click(function() {
			//$("#calandar").show();
			//this.addClass("layui-this");
			$("#mySchdule").hide();
			queryAttention();
		})
		//点击我的日程显示+
		$("#schduleli").click(function() {
			$("#mySchdule").show();
		});
		//编辑日程
		$("#editMySchdule").click(function() {
			//alert("1")
			updateMySchdule();
		});
		//显示关注详情
		function attention(obj) {
			id = obj.getAttribute("id");
			window.location.href = "${ctx}/workTable/showAttention?id=" + id;
		}
		
		function LimitTextArea(field){ 
			 maxlimit=50; 
			 if (field.value.length > maxlimit) {
			  field.value = field.value.substring(0, maxlimit); 
			   
			 }else{
				 $("#currNum").html(maxlimit-field.value.length);
			 }
			 return false;
		} 
		
		function numberLimit(field){ 
			 maxlimit=50; 
			 if (field.value.length > maxlimit) {
			  field.value = field.value.substring(0, maxlimit); 
			   
			 }else{
				 $("#num").html(maxlimit-field.value.length);
			 }
			 return false;
		} 
		
		function showContent(articleId){
			//alert(articleId)
			$.ajax({
				url : '${ctx}/repository/repositoryContent?articleId='+articleId, //服务器的地址
				dataType : 'json', //返回数据类型
				type : 'POST', //请求类型
				success : function(data) {
					//alert(data)
					if(data.content){
						$("#conceal").css("visibility","visible");
						$("#conceal").attr("onclick","javascript:JumpView("+articleId+")")
						$("#selectLidt").html(data.content);
						$("#search-text").val(data.keyWord);
						HiddenContent();
						$("#themes").html(data.theme);
						$("#themes").css("visibility","visible");
						$("#keywordName").css("visibility","hidden");
						$("#keywordName").empty();
						$("#selectLidt").show();
					}else{
						emptyData();
						$("#search-text").val(data.keyWord);
					}
				}
			});
		}
		
		function HiddenContent(){
			$("#repositoryView").hide();
			$("#auto").empty();
		}
		
		function JumpView(articleId){
			window.location.href = "${ctx}/repository/repositoryContentView?articleId=" + articleId;
		}
		
		function MouseOver(obj)
        {
            obj.style.backgroundColor = "#D1EEEE";
        }
         
        function MouseOut(obj)
        {
            obj.style.backgroundColor = "";
        }
        
        $(document).bind('click',function(e){ 
        	var e = e || window.event; //浏览器兼容性 
        	var elem = e.target || e.srcElement; 
        	while (elem) { //循环判断至跟节点，防止点击的是div子元素 
        		if (elem.id && elem.id=='receiverPerson') { 
        			return; 
        		} else if(elem.id && elem.id=='receive'){
        			var isShow = $('#receiverPerson').css('display');
        			if(isShow=="none"){
        				$('#receiverPerson').css('display','block');
        			}else{
        				$('#receiverPerson').css('display','none');
        			}
        			return;
        		}else if(elem.id && elem.id=='msgContent'){
        			return;
        		}else if(elem.className && elem.className=='user-span2'){
        			return;
        		}
        		elem = elem.parentNode; 
        	} 

        	$('#receiverPerson').css('display','none'); //点击的不是div或其子元素 
        }); 
        
        window.onpageshow = function(event) {
       	 	if($(window).width()<1345){
		        $("body").attr("style","min-width:1345px;")
            	$("body").css("overflow-x","auto");
            }
		};
        
        $(window).resize(function () {          //当浏览器大小变化时
            if($(window).width()<1345){
		        $("body").attr("style","min-width:1345px;")
            	$("body").css("overflow-x","auto");
            }
        });
	</script>
</body>
</html>